package com.ruoyi.web.controller.ies;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ies.domain.SugMasses;
import com.ruoyi.ies.service.ISugMassesService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 群众反馈Controller
 * 
 * @author July
 * @date 2023-06-09
 */
@RestController
@RequestMapping("/ies/masses")
public class SugMassesController extends BaseController
{
    @Autowired
    private ISugMassesService sugMassesService;

    /**
     * 查询群众反馈列表
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:list')")
    @GetMapping("/list")
    public TableDataInfo list(SugMasses sugMasses)
    {
        startPage();
        List<SugMasses> list = sugMassesService.selectSugMassesList(sugMasses);
        return getDataTable(list);
    }

    /**
     * 导出群众反馈列表
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:export')")
    @Log(title = "群众反馈", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SugMasses sugMasses)
    {
        List<SugMasses> list = sugMassesService.selectSugMassesList(sugMasses);
        ExcelUtil<SugMasses> util = new ExcelUtil<SugMasses>(SugMasses.class);
        util.exportExcel(response, list, "群众反馈数据");
    }

    /**
     * 获取群众反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:query')")
    @GetMapping(value = "/{sugId}")
    public AjaxResult getInfo(@PathVariable("sugId") Long sugId)
    {
        return success(sugMassesService.selectSugMassesBySugId(sugId));
    }

    /**
     * 新增群众反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:add')")
    @Log(title = "群众反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SugMasses sugMasses)
    {
        return toAjax(sugMassesService.insertSugMasses(sugMasses));
    }

    /**
     * 修改群众反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:edit')")
    @Log(title = "群众反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SugMasses sugMasses)
    {
        return toAjax(sugMassesService.updateSugMasses(sugMasses));
    }

    /**
     * 删除群众反馈
     */
    @PreAuthorize("@ss.hasPermi('ies:masses:remove')")
    @Log(title = "群众反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sugIds}")
    public AjaxResult remove(@PathVariable Long[] sugIds)
    {
        return toAjax(sugMassesService.deleteSugMassesBySugIds(sugIds));
    }
}
